﻿#include "CPolArea.h"

CPolArea::CPolArea()
{
}

CPolArea::~CPolArea()
{
}

void CPolArea::copyData(CPolArea * pPolArea)
{
	if (nullptr == pPolArea)
		return;

	pPolArea->resetData();
	pPolArea->m_sPolAreaGuid = m_sPolAreaGuid;
	pPolArea->m_sPolAreaName = m_sPolAreaName;
	pPolArea->m_sGuid = m_sGuid;
	pPolArea->m_nChargeNum = m_nChargeNum;

	//将map也拷贝
	for (QMap<QString, CPolPoint*>::iterator itor = m_mapPolPoint.begin(); itor != m_mapPolPoint.end(); itor++)
	{
		CPolPoint* pPolPoint = new CPolPoint();
		itor.value()->copyData(pPolPoint);
		pPolArea->m_mapPolPoint.insert(pPolPoint->m_sPointGuid, pPolPoint);
	}
}

void CPolArea::resetData()
{
	for (QMap<QString, CPolPoint*>::iterator itor = m_mapPolPoint.begin(); itor != m_mapPolPoint.end(); itor++)
	{
		if (itor.value() != nullptr)
			delete itor.value();
		itor.value() = nullptr;
	}
	m_mapPolPoint.clear();
}

QString CPolArea::getPointGuid(double nLocation)
{
	QString sReGuid = "";
	for (QMap<QString, CPolPoint*>::iterator itor = m_mapPolPoint.begin(); itor != m_mapPolPoint.end(); itor++)
	{
		if (itor.value()->m_dPointLocation == nLocation)
		{
			sReGuid = itor.value()->m_sPointGuid;
		}
	}
	return sReGuid;
}
